<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\home\models\FrontUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '前台用户列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="front-user-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('创建前台用户', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],

            [
                'attribute' => 'id',
                'value' => 'id',
                'headerOptions' => ['width' => '50'],
            ],
            [
                'label' => '公司名称',
                'format' => 'raw',
                'attribute' => 'company_name',
                'value' => function($model) {
                    return $model->company_name;
                },
            ],
            [
                'label' => '用户名',
                'format' => 'raw',
                'attribute' => 'username',
                'value' => function($model) {
                    return $model->username;
                },
            ],
            [
                'label' => '邮件',
                'format' => 'raw',
                'attribute' => 'email',
                'value' => function($model) {
                    return $model->email;
                },
            ],
            [
                'label' => '状态',
                'format' => 'raw',
                'attribute' => 'status',
                'value' => function($model) {
                    if($model->status == 10){
                        return '<span class="btn btn-success btn-xs">可用</span>';
                    }else{
                        return '<span class="btn btn-danger btn-xs">不可用</span>';
                    }
                },
                'filter' => ['0' => '禁用', '10' => '可用'],
            ],
            [
                'label' => '创建时间',
                'format' => 'raw',
                'attribute' => 'created_at',
                'value' => function($model) {
                    return date('Y-m-d H:i',$model->created_at);
                },
            ],
        ],
    ]); ?>
</div>
